package com.saihai.jiankang.ufZhglDt1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufZhglDt1.domain.UfZhglDt1;
import com.saihai.jiankang.ufZhglDt1.service.IUfZhglDt1Service;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 角色关联Controller
 * 
 * @author ruoyi
 * @date 2024-08-05
 */
@RestController
@RequestMapping("/jiankang/ufZhglDt1")
public class UfZhglDt1Controller extends BaseController
{
    @Autowired
    private IUfZhglDt1Service ufZhglDt1Service;

    /**
     * 查询角色关联列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:list')")
    @GetMapping("/list")
    public TableDataInfo list(UfZhglDt1 ufZhglDt1)
    {
        startPage();
        List<UfZhglDt1> list = ufZhglDt1Service.selectUfZhglDt1List(ufZhglDt1);
        return getDataTable(list);
    }

    /**
     * 导出角色关联列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:export')")
    @Log(title = "角色关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfZhglDt1 ufZhglDt1)
    {
        List<UfZhglDt1> list = ufZhglDt1Service.selectUfZhglDt1List(ufZhglDt1);
        ExcelUtil<UfZhglDt1> util = new ExcelUtil<UfZhglDt1>(UfZhglDt1.class);
        util.exportExcel(response, list, "角色关联数据");
    }

    /**
     * 获取角色关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufZhglDt1Service.selectUfZhglDt1ById(id));
    }

    /**
     * 新增角色关联
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:add')")
    @Log(title = "角色关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfZhglDt1 ufZhglDt1)
    {
        return toAjax(ufZhglDt1Service.insertUfZhglDt1(ufZhglDt1));
    }

    /**
     * 修改角色关联
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:edit')")
    @Log(title = "角色关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfZhglDt1 ufZhglDt1)
    {
        return toAjax(ufZhglDt1Service.updateUfZhglDt1(ufZhglDt1));
    }

    /**
     * 删除角色关联
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufZhglDt1:remove')")
    @Log(title = "角色关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufZhglDt1Service.deleteUfZhglDt1ByIds(ids));
    }
}
